

//
//  startAndStopView.m
//  didihaha
//
//  Created by zzp on 2017/8/22.
//  Copyright © 2017年 zhaozhongpeng. All rights reserved.
//

#import "startAndStopView.h"
#import "Masonry.h"
#import "DiDiShareInstance.h"

@implementation startAndStopView

- (instancetype)init{
    if (self = [super init]) {
        self.backgroundColor = [UIColor whiteColor];
        [self createUI];
        self.layer.cornerRadius = 3;
        self.layer.shadowColor = [UIColor lightGrayColor].CGColor;
        self.layer.shadowOffset = CGSizeMake(0,-2);
        self.layer.shadowOpacity = 0.5;
        self.layer.borderWidth = 0.1;
        self.layer.borderColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:240/255.0 alpha:1].CGColor;
    }
    return self;
}

- (void)createUI{
    
    UIView *line = [[UIView alloc] init];
    line.backgroundColor = [UIColor colorWithRed:229/255.0 green:229/255.0 blue:229/255.0 alpha:1];
    [self addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(40);
        make.centerY.equalTo(self.mas_centerY);
        make.height.mas_equalTo(1);
    }];
    
    UIImageView *startImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"form_icon_start"]];
    [self addSubview:startImageView];
    [startImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(10);
        make.centerY.equalTo(self.mas_top).offset(22);
        make.height.width.mas_equalTo(6);
    }];
    
    UIImageView *stopImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"form_icon_end"]];
    [self addSubview:stopImageView];
    [stopImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.height.width.equalTo(startImageView);
        make.centerY.equalTo(self.mas_bottom).offset(-22);
    }];
    
    
    UIImageView *soundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"form_icon_voice_normal"]];
    [self addSubview:soundImageView];
    [soundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-10);
        make.centerY.equalTo(stopImageView);
        make.height.width.mas_equalTo(15);
    }];
    
    UITextField *fromTextField = [[UITextField alloc] init];
    fromTextField.font = [UIFont systemFontOfSize:12];
    fromTextField.textColor = [UIColor colorWithRed:135/255.0 green:135/255.0 blue:135/255.0 alpha:1];
    fromTextField.text = @"广安门内 - 信息大厦";
    
    if ([[[DiDiShareInstance shareInstance].dataDic objectForKey:@"defalutLocation"] length] > 0) {
        fromTextField.text = [[DiDiShareInstance shareInstance].dataDic objectForKey:@"defalutLocation"];
    }
    
    [self addSubview:fromTextField];
    
    [fromTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(line.mas_left);
        make.centerY.equalTo(startImageView.mas_centerY);
        make.right.equalTo(self);
    }];
    
    UITextField *toTextField = [[UITextField alloc] init];
    toTextField.font = [UIFont systemFontOfSize:12];
    toTextField.textColor = [UIColor colorWithRed:135/255.0 green:135/255.0 blue:135/255.0 alpha:1];
    toTextField.placeholder = @"你要去那儿";
    [self addSubview:toTextField];
    [toTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(line.mas_left);
        make.centerY.equalTo(stopImageView.mas_centerY);
        make.right.equalTo(soundImageView.mas_left);
    }];
    
}

@end
